﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PlatypusPlanner.Components.BLL;
using PlatypusPlanner.Components.Database;
using PlatypusPlanner.Components.Enumerations;

namespace PlatypusPlanner.UserControls
{
    public partial class RegistrationForm : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void submit_Click(object sender, EventArgs e)
        {
            //This is used to send data from the page to the SQL Database Taskify tf_user
            if (Page.IsValid)
            {
                UserCreationStatus status = UserCreationStatus.NotSet;
                new Users().InsertUpdate(null, emailTxt.Text, firstNameTxt.Text, lastNameTxt.Text, addressTxt.Text, cityTxt.Text, stateTxt.Text,
             zipTxt.Text, passwordTxt.Text, out status);
                switch (status)
                {
                    case UserCreationStatus.Success:
                        break;
                    case UserCreationStatus.GeneralError:
                        errorMessageLbl.Visible = true;
                        errorMessageLbl.Text = "Sorry for the inconvience, an error has occurred. Please contact tech support.";
                        break;
                    case UserCreationStatus.DuplicateEmail:
                        errorMessageLbl.Visible = true;
                        errorMessageLbl.Text = "Sorry, this email already exists, please input a different email or use the forgoten password.";
                        break;
                }


            }

        }
    }
}